{% extends 'PHPDishWebBundle::layout.html.twig' %}

{% block title %} {{ thread ? 'thread.edit_thread'|trans : 'thread.add_thread'|trans}} {% endblock %}
{% block script %}
    <script type="text/javascript" src="{{ asset('build/js/thread.js') }}"></script>
{% endblock %}

{% block content %}
    <div class="container narrow-layout" role="main">
        <div class="row">
            <article class="col-md-12">
                <div class="panel panel-u add-thread">
                    <div class="panel-heading">{{ thread ? 'thread.edit_thread'|trans : 'thread.add_thread'|trans}}</div>
                    {% from 'PHPDishWebBundle:Macros:notification.html.twig' import flashes %}
                    <div class="panel-body">
                        {{ flashes() }}
                        {{ form_start(form, {'attr': {'id': 'add-thread-form', 'class': 'thread'}}) }}
                        {{ form_errors(form) }}
                            <div class="form-group">
                                {{ form_label(form.name) }}
                                {{ form_widget(form.name, {'attr': {'class': 'form-control name', placeholder: 'thread.form.name'|trans}}) }}
                                {{ form_errors(form.name) }}
                            </div>
                            <div class="form-group">
                                {{ form_label(form.description) }}
                                {{ form_widget(form.description, {'attr': {'class': 'form-control description', placeholder: 'thread.form.description'|trans}}) }}
                                {{ form_errors(form.description) }}
                            </div>
                            <div class="form-group">
                                {{ form_label(form.slug) }} {{ url('thread_view', {'slug': 'domain'})|raw }}
                                {{ form_widget(form.slug, {'attr': {'class': 'form-control slug', placeholder: 'thread.form.slug'|trans}}) }}
                                {{ form_errors(form.slug) }}
                            </div>
                            <div class="form-group upload-cover clearfix {% if thread.cover %}uploaded{% endif %}" id="upload-cover">
                                <div id="pick-image" class="upload-camera-icon"><i class="if i-camera"></i></div>
                                <div class="preview-image">
                                    <img data-role="preview" class="img-responsive" src="{% if thread.cover %}{{ thread.cover|media_url_build }}{% endif %}"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <button type="submit" class="btn u-btn-primary">
                                    {% if thread is defined %}{{ 'ui.edit'|trans }}{% else %}<i class="if i-plus-bold"></i> {{ 'ui.create'|trans }}{% endif %}
                                </button>
                            </div>
                        {{ form_end(form) }}
                    </div>
                </div>
            </article>
        </div>
    </div>

{% endblock %}